<template>
  <div style="width: 100%;height: 150px;background-color: chocolate">
    userName:{{userName}}<br/>
    password:{{password}}<br/>
    <span v-text="sex"></span>
    <button @click="$emit('execfun')">调用父组件的方法1</button>
    <button @click="doFun">调用父组件的方法2</button>
  </div>



</template>

<script setup>
const props = defineProps({
  userName:{
    type:[String],
    required:true,
    validator(value) {
      return value!=null && value.length>5
    }
  },
  password:{
    type:String,
    default:'000000'
  },
  sex:{
    type:String,
    required:true //必须传递
  }
})

const emit = defineEmits(['fun01','fun02'])

function doFun(){
  emit('fun01','张三','123456',22)
}


</script>

<style scoped>

</style>